package com.game.activity.pager;

import com.element.character.player.Player;
import com.example.quest.R;

import android.content.Context;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

/**
 * This is an extended class of PagerAdapter which
 * 
 * 
 * @author Rasmus
 */

public class MainPagerAdapter extends PagerAdapter {
	public static final int INT_PAGE_AMOUNT = 6;
	@Override
	public int getCount() {
		return INT_PAGE_AMOUNT;
	}

	public MainPagerAdapter(){
		super();
	}
	
	@Override
	public boolean isViewFromObject(View view, Object obj) {
		return view == ((View) obj);
	}
	
	public Object instantiateItem(View collection, int position) {
        LayoutInflater inflater = (LayoutInflater) collection.getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        int resId = 0;
        switch (position) {
        case 0:
            resId = R.layout.activity_menu_statistics;
            break;
        case 1:
            resId = R.layout.activity_menu_inventory;
            break;
        case 2:
            resId = R.layout.activity_menu_map;
            break;
        case 3:
            resId = R.layout.activity_menu_character;
            break;
        case 4:
            resId = R.layout.activity_menu_quests;
            break;
        case 5:
            resId = R.layout.activity_menu_progress;
            break;
        }
        View view = inflater.inflate(resId, null);
        ((ViewPager) collection).addView(view, 0);
        initializeView(view, resId);
        return view;
    }
	
	private void initializeView(View view, int resId) {
		switch (resId) {
        case R.layout.activity_menu_statistics:
            // activity_statistics;
            break;
        case R.layout.activity_menu_inventory:
            // activity_inventory;
            TextView test = (TextView) view.findViewById(R.id.itemDescriptionTextView);
    	    test.setMovementMethod(new ScrollingMovementMethod());
            break;
        case R.layout.activity_menu_map:
            // activity_map;
            break;
        case R.layout.activity_menu_character:
        	// activity_character;
            break;
        case R.layout.activity_menu_quests:
            // activity_quests;
            break;
        case R.layout.activity_menu_progress:
            // activity_progress;
            break;
        }
	}
	
	@Override
	public void destroyItem(View view, int argInt, Object obj) {
        ((ViewPager) view).removeView((View) obj);
    }
	
	@Override
	public Parcelable saveState() {
        return null;
    }
}
